package com.sixth.controller;

import com.sixth.bean.common.BaseRespVo;
import com.sixth.bean.vo.StatisticsVO;
import com.sixth.constant.Constant;
import com.sixth.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author Chen
 * @Date 2022-09-09  14-30-13
 * @description  统计平台数据
 */
@RestController
@RequestMapping("admin/stat/")
public class StatisticsController {

    @Autowired
    StatisticsService statisticsService;

    /**
     * @Author Chen
     * @Date 2022-09-09  14-30-57
     * @param
     * @return {@link null }
     * @description  按日统计用户增长数
     */
    @GetMapping("user")
    public BaseRespVo userStatistics(){

        StatisticsVO userStatisticsVO = statisticsService.getUserUpNum();

        if (userStatisticsVO.getRows().size()>= Constant.ONE){

            return BaseRespVo.ok(userStatisticsVO);
        }

        return BaseRespVo.invalidParameter("暂无用户");
    }


    /**
     * @Author Chen
     * @Date 2022-09-09  16-31-14
     * @param
     * @return {@link null }
     * @description 按日统计订单数据
     */
    @GetMapping("order")
    public BaseRespVo orderStatistics(){

        StatisticsVO orderStatisticsVO = statisticsService.getOrderStatistics();

        if (orderStatisticsVO.getRows().size()>= Constant.ONE){

            return BaseRespVo.ok(orderStatisticsVO);
        }

        return BaseRespVo.invalidParameter("暂无用户");

    }

    @GetMapping("goods")
    public BaseRespVo  goodsStatistics(){

        StatisticsVO goodsStatisticsVO = statisticsService.getGoodsStatistics();

        if (goodsStatisticsVO.getRows().size()>= Constant.ONE){

            return BaseRespVo.ok(goodsStatisticsVO);
        }
        return BaseRespVo.invalidParameter("暂无用户");
    }

}
